#ifndef RAND_H_
#define RAND_H_

#include "Field.h"
#include "chacha.h"

class MyRandom
{
public:
    __device__ MyRandom();

    __device__ uint64_t init(CuByteArray epoch_hash,CuByteArray address,uint64_t counter);
    __device__ void setDebug(bool flag);
    __device__ int genTime();

    __device__ Boolean rand_bool();

    __device__ Integer rand_i8();
    __device__ Integer rand_i16();
    __device__ Integer rand_i32();
    __device__ Integer rand_i64();
    __device__ Integer rand_i128();

    __device__ Integer rand_u8();
    __device__ Integer rand_u16();
    __device__ Integer rand_u32();
    __device__ Integer rand_u64();

    __device__ Field rand_field();

    __device__ uint32_t next_u32();
    __device__ uint64_t next_u64();

protected:
    __device__ void generate_and_set(int index);
    __device__ uint64_t sha256_u64(uint8_t* buffer, int len);
    __device__ uint256_t to_bigint(uint256_t in);
    bool m_log;

    int index;
    int m_genTime;
    ChaCha m_rng;
    CuVector<uint32_t> results;
};

#endif // 
